<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <!-- INTERFACE -->
    <cc:interface>
    </cc:interface>

    <!-- IMPLEMENTATION -->
    <cc:implementation>
        <p:dataTable id="tblBills" value="#{searchController.bills}" var="bill">
            <p:column>
                <p:commandButton ajax="false" value="View Bill" action="inward_reprint_bill_professional">
                    <f:setPropertyActionListener value="#{bill}" target="#{inwardSearch.bill}"/>
                </p:commandButton>
            </p:column>

            <p:column headerText="Bill No"  >
                <h:outputLabel value="#{bill.insId}" ></h:outputLabel>
            </p:column>

            <p:column headerText="Bht No" >
                <h:outputLabel value="#{bill.patientEncounter.bhtNo}" ></h:outputLabel>
            </p:column>

            <p:column headerText="Billed At" >   
                <h:outputLabel value="#{bill.createdAt}" />>
                <br/>
                <h:panelGroup rendered="#{bill.cancelled}" >
                    <h:outputLabel style="color: red;" value="Cancelled at " />
                    <h:outputLabel style="color: red;" rendered="#{bill.cancelled}" value="#{bill.cancelledBill.createdAt}" >
                        <f:convertDateTime pattern="dd MMM yyyy hh mm a"/>
                    </h:outputLabel>
                </h:panelGroup>                             
            </p:column>

            <p:column headerText="Billed By">  
                <h:outputLabel value="#{bill.creater.webUserPerson.name}" >                                      
                </h:outputLabel>                                  
                <br/>
                <h:panelGroup rendered="#{bill.cancelled}" >
                    <h:outputLabel style="color: red;" value="Cancelled By " />
                    <h:outputLabel style="color: red;" rendered="#{bill.cancelled}" value="#{bill.cancelledBill.creater.webUserPerson.name}" >                                       
                    </h:outputLabel>
                </h:panelGroup>
            </p:column>

            <p:column headerText="Client" >
                <h:outputLabel value="#{bill.patientEncounter.patient.person.nameWithTitle}" ></h:outputLabel>
            </p:column>         
            <p:column headerText="PaymentMethod">                            
                <h:outputLabel value="#{bill.paymentMethod}" ></h:outputLabel>                                   
            </p:column>
            <p:column headerText="Value" >                              
                <h:outputLabel value="#{bill.netTotal}" >
                    <f:convertNumber pattern="#,##0.00"/>
                </h:outputLabel>                                  
            </p:column>                                
            <p:column headerText="Comments" >
                <h:outputLabel rendered="#{bill.refundedBill ne null}" value="#{bill.refundedBill.comments}" >
                </h:outputLabel>
                <h:outputLabel  rendered="#{bill.cancelledBill ne null}" value="#{bill.cancelledBill.comments}" >
                </h:outputLabel>
            </p:column>
        </p:dataTable>
    </cc:implementation>
</html>